|
|
|
|
|
|
|
1. Create a property by using the Property Let and Property Get procedures. You can create the shell of the property by using the Add Procedure dialog box, which you can access from the Tools menu of Visual Basic. |
|
|
|
|
|
|
|
|
2. To indicate that the value of a property has changed, place the PropertyChanged statement in the Property Let procedure of each property whose value you want to store. |
|
|
|
|
|
|
|
|
3. To store the values of the property, use the WriteProperty method of the PropertyBag object to output the values of the changed properties. The code for this method is placed in the WriteProperties event of the UserDocument. |
|
|
|
|
|
|
|
|
4. To retrieve the values of the property, use the ReadProperty method of the PropertyBag object to output the values of the changed properties. The code for this method is placed in the ReadProperties event of the UserDocument. |
|
|
|
|
|
|
|
|
See ''Adding Properties" p. 331 |
|
|
|
|
|
|
|
|
The result of the code for handling these tasks in a sample document is shown in Figure 32.9. |
|
|
|
|
|
|
|
|
Figure 32.9
Use the ReadProperty and WriteProperty methods to
retrieve and store public properties of the UserDocument. |
|
|
|
|
|
|
|
|
Working with the Methods of the UserDocument |
|
|
|
|
|
|
|
|
In addition to the different events that UserDocument supports, the UserDocument also supports two key methods that a form does not: AsyncRead and CancelAsyncRead. The AsyncRead method enables the document to request that its container read in data from a file or URL. As the name implies, the read is performed asynchronously. As you can imagine, the ability to read a file asynchronously comes in handy when you're working with the Internet. For example, you might write a data viewer application that retrieves information from a server. The AsyncRead method requires that you specify the file (or information) to be read and the type of information that is being read. The three supported data types are summarized in Table 32.2. |
|
|
|
|
|